package test4.noLock;


public class AppWithoutLock {
    public static void main(String[] args) throws InterruptedException {
        AccountWithoutLock a = new AccountWithoutLock(1, "A", 10);
        AccountWithoutLock b = new AccountWithoutLock(2, "B", 10);
        System.out.println("开始时, 账户a余额" + a.getBalance());
        System.out.println("开始时, 账户b余额" + b.getBalance());
        Thread thread1 = new Thread(() -> AccountWithoutLock.transferTo(b, a, 1));
        Thread thread2 = new Thread(() -> AccountWithoutLock.transferTo(a, b, 3));

        thread1.start();
        thread2.start();
        System.out.println("结束时, 账户a余额" + a.getBalance());
        System.out.println("结束时, 账户b余额" + b.getBalance());
    }
}
